package com.menggudf.common;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.menggudf.entity.CommonSymptom;
import com.menggudf.service.IllnessService;

@Component
public class CommonSymptomTask {
    
    private static final Logger LOGGER = LoggerFactory
            .getLogger(CommonSymptomTask.class.getName());
    
    @Autowired
    IllnessService illnessService;
    
    public void synCommonSymptom(){
        List<CommonSymptom> list = illnessService.getAllCommonSymptom();
        List<Integer> ids = new ArrayList<Integer>();
        List<String> names = new ArrayList<String>();
        for(CommonSymptom cs : list){
            if(!illnessService.hasSymptom(cs.getSymptom())){
                ids.add(cs.getId());
                names.add(cs.getSymptom());
            }
        }
        illnessService.deleteCommonSymptomByIds(ids);
        LOGGER.info("同步成功");
        LOGGER.info("删除数据："+names.toString());
    }

    public static void main(String[] args) {
        new CommonSymptomTask().synCommonSymptom();
    }
}
